
#include <stdint.h>
#include <unistd.h>
#include <string.h>
#include <stdint.h>
#include <sys/types.h>
#include "autoconfig.h"
#include "sys/err.h"
#include "apitrans.h"


extern sys_apitrans_t sysapi;


int icc_status( uint8_t *status, int *status_len )
{
   
   int (*picc_status)( uint8_t *status, int *status_len );
   
   picc_status = sysapi(ICC_STATUS_API);
   if (picc_status) {
       return picc_status(status, status_len);
   }
   return -API_UNSUPPORTED_ERR;

}

int icc_send_apdu( int cardno, uint8_t* in, int inlen, uint8_t *out, int *outlen )
{
    int (*picc_send_apdu)( int cardno, uint8_t* in, int inlen, uint8_t *out, int *outlen );
    
    picc_send_apdu = sysapi(ICC_SEND_APDU_API);
    if (picc_send_apdu) {
        return picc_send_apdu(cardno, in, inlen, out, outlen);
    }
    return -API_UNSUPPORTED_ERR;
}


int icc_power_down( int cardno )
{
    int (*picc_power_down)( int cardno );
    
    picc_power_down = sysapi(ICC_POWER_DOWN_API);
    if (picc_power_down) {
        return picc_power_down(cardno);
    }
    return -API_UNSUPPORTED_ERR;
}

int icc_power_up( int cardno, uint8_t *out, int *outlen )
{
    int (*picc_power_up)( int cardno, uint8_t *out, int *outlen );
    
    picc_power_up = sysapi(ICC_POWER_UP_API);
    if (picc_power_up) {
        return picc_power_up(cardno, out, outlen);
    }
    return -API_UNSUPPORTED_ERR;

}

